﻿@using PBDesk.Umbraco.Helper; 
@using umbraco.MacroEngines;
@{ int maxLevelForSitemap = 5; }
@{ var courseLevelNode = Model.AncestorsOrSelf().Where("Level == 3").Items[0]; }

<div id="courseMapPopup">
  <br />
  <a href="@courseLevelNode.NiceUrl">Course Home</a>
  <ul style="padding-left:20px">
    @if (courseLevelNode.Children.Count() > 0)
    {
      foreach (var chapter in courseLevelNode.Children)
      {
          <li><a href="@chapter.NiceUrl">@chapter.Name</a></li>
          if (chapter.Children.Count() > 0)
          {
              <ul style="padding-left:20px">
                foreach(var page in chapter.Children)
                {
                 <li><a href="@page.NiceUrl">@page.Name</a></li>
                }
              </ul>
          }
      }
    }
  </ul>
</div>
